module(..., package.seeall)

local atan2 = math.atan2
local sqrt  = math.sqrt


function angle(x0, y0, x1, y1)
    --[[ Computes the angle *IN RADIANS* between a vector and the x-axis in 2D space. ]]
    return atan2(y1 - y0, x1 - x0)
end

function squared_distance(x0, y0, x1, y1)
    --[[ Squared distance between two points in 2D space. ]]
    local dx, dy = x1 - x0, y1 - y0
    return dx * dx + dy * dy
end

function distance(x0, y0, x1, y1)
    --[[ Computes Euclidean distance between two points in 2D space. ]]
    return sqrt(squared_distance(x0, y0, x1, y1))
end
